package com.mstafkumax.ismamazigh;

import java.util.Date;

public class DateAmazigh {
	String miData;
	String fecha;
	String fechaLocal;
	DateAmazigh(){
		Date data = new Date();
		fecha = data.toString();//Tue Jun 22 13:07:00 PDT 1999
		fechaLocal=data.toLocaleString();
	}
	public String getDateAmazigh(){
		String year, moonth, day, nameDay; 		
		//nombre del dia. lunes, martes...
		nameDay=fecha.split(" ")[0];
		//day
		day=fecha.split(" ")[2];
		//moonth
		moonth=fecha.toString().split(" ")[1];
		// year
		year = fecha.split(" ")[5];		
		//  juntar fecha
		miData= getNameDay(nameDay)+" "+day+" "+getMoonth(moonth)+" "+getYear(year, day,moonth)+" "+getSeason(year, nameDay, moonth);
		if(miData.contains("ERROR")){miData="";}
		miData+=",  "+fechaLocal;
		return miData;	
	}
	private String getYear(String year, String day, String moonth) {
		int miYear= Integer.parseInt(year);
		miYear+=950;
		if(moonth.equals("Jan") && Integer.parseInt(day)<12){miYear-=1;}
		year=String.valueOf(miYear);
		return year;
		
	}
	private String getMoonth(String moonth) {
		String miMoonth="";
		String[] arrayMoonth ={"innayr","xubrayr","mars","ibrir","mayyuh","yunyu","yulyu","γuct","cutanbir","kṭuber","duwanbir","dujanbir",};
		if(moonth.equals("Jan")){miMoonth=arrayMoonth[0];}
		else if(moonth.equals("Feb")){miMoonth=arrayMoonth[1];}
		else if(moonth.equals("Mar")){miMoonth=arrayMoonth[2];}
		else if(moonth.equals("Apr")){miMoonth=arrayMoonth[3];}
		else if(moonth.equals("May")){miMoonth=arrayMoonth[4];}
		else if(moonth.equals("Jun")){miMoonth=arrayMoonth[5];}
		else if(moonth.equals("Jul")){miMoonth=arrayMoonth[6];}
		else if(moonth.equals("Aug")){miMoonth=arrayMoonth[7];}
		else if(moonth.equals("Sep")){miMoonth=arrayMoonth[8];}
		else if(moonth.equals("Oct")){miMoonth=arrayMoonth[9];}
		else if(moonth.equals("Nov")){miMoonth=arrayMoonth[10];}
		else if(moonth.equals("Dec")){miMoonth=arrayMoonth[11];}
		else {miMoonth= "ERROR";}
		return miMoonth;
	}
	private String getSeason(String year, String day, String moonth){
		String season = "";
		return season;
	}
	private String getNameDay(String day){
		String miDay="";
		String[] arrayDays = {"Arim","Aram","Ahad","Amhad",	"Sem","Sed","Acer"};
		if(day.equals("Mon")){miDay=arrayDays[0];}
		else if(day.equals("Tue")){miDay=arrayDays[1];}
		else if(day.equals("Wed")){miDay=arrayDays[2];}
		else if(day.equals("Thu")){miDay=arrayDays[3];}
		else if(day.equals("Fri")){miDay=arrayDays[4];}
		else if(day.equals("Sat")){miDay=arrayDays[5];}
		else if(day.equals("Sun")){miDay=arrayDays[6];}
		//else {miDay= "ERROR";}
		return miDay;		
	}
}
